<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h3>javaScript访问DOM数案例</h3>
		<a  href="http://www.taobao.com"  target="_blank">淘宝</a>
		<a class="jd" href="http://www.jd.com"   target="_blank">京东</a>
		<a  name="pdd" href="http://www.pinduoduo.com"   target="_blank">拼多多</a>
		<a id="cgb" href="http://act.codeboy.com" target="_blank">java培优</a>
		<script>
			alert('您访问的网页是黄色网站')  //提供弹出框api
			// alert( document.getElementsByTagName("a")[2])
			// alert( document.getElementsByTagName("a")[2].innerText)
			//第一种方式TagName
			console.log(document.getElementsByTagName("a")[0].innerText)
			console.log(document.getElementsByTagName("a")[0].href)
			//第二种方式ClassName
			 console.log(document.getElementsByClassName("jd")[0].innerText)
			 console.log(document.getElementsByClassName("jd")[0].href)
			//第三种方式name
			console.log(document.getElementsByName("pdd")[0].innerText)
			console.log(document.getElementsByName("pdd")[0].href)
			//第三种方式id
			console.log(document.getElementById("cgb").innerText)
			console.log(document.getElementById("cgb").href)
			
			var a=document.getElementsByTagName("a")[2]
			a.innerText="百度"
			a.href="http://www.baidu.com"
		</script>
	</body>
</html>
